﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using OLTS.DATA_SERVICE;
using OLTS.MODEL;
using OLTS.WEB.BaseClass;

namespace ONTS.WEB.Views
{
    public partial class HolidayKeyIn : BaseWebpage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["LOGIN"] == null)
                {
                    Response.Redirect("/AccessDeniedPage.aspx", false);
                }
                else
                {
                    var model = BaseService.LOGIN;
                    var role = model.ROLE.Split(':');
                    if (!role.Contains("administrator"))
                    {
                        Response.Redirect("/AccessDeniedPage.aspx", false);
                    }
                }

                ClearDdl();
                int year = GetYear();
                ddlYear.Items.Add((year - 1).ToString());
                ddlYear.Items.Add(year.ToString());
                ddlYear.SelectedIndex = 1;


                foreach (var a in Utility.getSiteAll())
                {
                    ddlSite.Items.Add(new ListItem(a.NAME, a.ID.ToString()));
                } 

                //this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Test", "test('" + new JavaScriptSerializer().Serialize(lst) + "')", true);
            }
        }
        private void ClearDdl()
        {

        }
        private int GetYear()
        {
            System.Globalization.CultureInfo USCulture = new System.Globalization.CultureInfo("en-US", true);
            return Convert.ToInt16(DateTime.Now.ToString("yyyy", USCulture));
        }
    }
}